import { createApp } from 'vue'
import './style.css'
import './assets/apple-design.css'
import App from './App.vue'
import router from './router'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import { createPinia } from 'pinia'
import axios from 'axios'

// 配置axios默认值
// 检测当前环境
const isDocker = window.location.hostname !== 'localhost' || window.location.port !== '5173'
console.log('当前环境:', isDocker ? 'Docker' : '开发环境')
console.log('当前URL:', window.location.href)

// 根据环境设置baseURL
if (isDocker) {
  // Docker环境
  axios.defaults.baseURL = ''  // 使用相对路径，依赖Nginx代理
  console.log('使用Docker环境配置')
} else {
  // 开发环境
  axios.defaults.baseURL = 'http://localhost:8080'
  console.log('使用开发环境配置')
}

console.log('Axios baseURL:', axios.defaults.baseURL)
axios.defaults.headers.common['Content-Type'] = 'application/json'
axios.defaults.timeout = 10000

const app = createApp(App)
const pinia = createPinia()

app.use(router)
app.use(ElementPlus)
app.use(pinia)
app.mount('#app')
